﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebUI
{
    public partial class Users : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!IsPostBack)
            {
                POSSystem.BLL.Users u = POSSystem.BLL.Users.GetAllActiveUsers();
                lstUsers.UserList = u;
                lstUsers.Refresh();
            }
        }

        protected void RefreshUserList()
        {
            lstUsers.Filter = "Deleted = 0";
            lstUsers.Refresh();
        }

        public string GetUserEditPageLink()
        {
            return "EditPages/EditUser.aspx?key=" + lstUsers.SourceObjectSessionID;
        }

        protected void btnAddUser_OnClick(object sender, EventArgs e)
        {
            RefreshUserList();
        }

        protected void btnEditUser_OnClick(object sender, EventArgs e)
        {
            RefreshUserList();
        }

        protected void btnRemoveUser_OnClick(object sender, EventArgs e)
        {
            lstUsers.CurrentPageIndex = 0;
            lstUsers.DeleteCheckedItems();
            RefreshUserList();
        }
    }
}